home *** CD-ROM | disk | FTP | other *** search
/ PC User 2003 December / Australian PC User - December 2003 (CD2).iso / software / apps / files / dwmx2k4.exe / Disk1 / data1.cab / Configuration_En / Commands / Source Formatting Selection.js < prev    next >
Encoding:
JavaScript  |  2003-09-05  |  1.4 KB  |  44 lines

  1. // Copyright 2001, 2002, 2003 Macromedia, Inc. All rights reserved.
  2. //-----------------------------------------------------
  3. //
  4. // Source Formatting Selection.js
  5. //
  6. // This file contains the implementation to fire off the Dreamweaver
  7. // source formatter to the selection.
  8.  
  9. function canAcceptCommand(){
  10.   var retVal = true;
  11.   var dom = dw.getDocumentDOM();
  12.  
  13.   if (dom && (dom.getParseMode() == 'html' || dw.getDocumentDOM().getParseMode() == 'xml') && (dw.getFocus() == 'document' || dw.getFocus(true) == 'html' || dw.getFocus() == 'textView')){
  14.     var selArr = dom.getSelection();
  15.     if (selArr[0] == selArr[1]){
  16.       retVal = false;
  17.     }else if (dom.getSelectedNode().nodeType == Node.ELEMENT_NODE && dom.getSelectedNode.tagName == 'TABLE'){
  18.       var sourceSel = dom.source.getSelection();
  19.       alert("sourceSel = " + sourceSel);
  20.       var TRs = dom.getSelectedNode().getElementsByTagName('TR');
  21.       var offsets;
  22.       for (var i=0; i < TRs.length; i++){
  23.         offsets = dom.nodeToOffsets(TRs[i]);
  24.         alert("offsets = " + offsets);
  25.         if ((offsets[0] == sourceSel[0]) && (offsets[1] == sourceSel[1])){
  26.           retVal = false;
  27.           break;
  28.         }
  29.       }
  30.     }
  31.   }else{
  32.     retVal = false;
  33.   }
  34.  
  35.    return retVal;
  36. }
  37.  
  38. function formatSourceSelection()
  39. {
  40.    dw.getDocumentDOM().formatSelection();
  41.    
  42.    return;         
  43. }
  44.